package com.swyc.osschat.Test.LambdaTest.Bean;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.google.common.collect.ImmutableList;
import com.swyc.osschat.Test.StreamTest.Bean.SpecialityEnum;

/**
 * @author zhaol@yunrong.cn
 * @version V2.1
 * @since 2.1.0 2019/8/9 10:24
 */
public class Student {
    private Integer id;
    private String name;
    private Integer age;
    private Integer stature;
    /** 性别：1.男   2.女 */
    private String sex = "1";
    /** 配偶 */
    private Integer spouse;

    public static Student student = new Student(9,"藏海花", 77, 201, ImmutableList.of(SpecialityEnum.RUNNING,SpecialityEnum.SING),"2",null);
    private Long Airs;
    private List<SpecialityEnum> specialityEnums;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getStature() {
        return stature;
    }

    public void setStature(Integer stature) {
        this.stature = stature;
    }

    public List<SpecialityEnum> getSpecialityEnums() {
        return specialityEnums;
    }

    public void setSpecialityEnums(List<SpecialityEnum> specialityEnums) {
        this.specialityEnums = specialityEnums;
    }

    public Long getAirs() {
        return Airs;
    }

    public void setAirs(Long airs) {
        Airs = airs;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public Integer getSpouse() {
        return spouse;
    }

    public void setSpouse(Integer spouse) {
        this.spouse = spouse;
    }

    public Student(Integer id,String name,Integer age,Integer stature,List<SpecialityEnum> list,String sex,Integer spouse){
        this.id = id;
        this.sex = sex;
        this.spouse = spouse;
        this.name = name;
        this.age = age;
        this.stature = stature;
        this.specialityEnums = list;
    }
    public Student(String name,Integer age,Integer stature){
        this.name = name;
        this.age = age;
        this.stature = stature;
    }


    public static String beanToString(Student s){
        return new StringBuilder("Student:")
            .append("name=")
            .append(s.getName())
            .append(",")
            .append("age=")
            .append(s.getAge())
            .append(",")
            .append("stature=")
            .append(s.getStature())
            .toString();
    }

    public static int getStudentAge(Student s){
        return s.getAge();
    }

    /**
     * 生成一个集合
     * @return
     */
    public static List<Student> generateData(){
        List<Student> students = new ArrayList<>(3);
        students.add(new Student(1,"白胡子", 50, 185,ImmutableList.of(SpecialityEnum.SING,SpecialityEnum.DANCE,SpecialityEnum.RUNNING),"1",4));
        students.add(new Student(2,"母夜叉", 82, 167,ImmutableList.of(SpecialityEnum.SWIMMING,SpecialityEnum.DANCE,SpecialityEnum.RUNNING),"2",8));
        students.add(new Student(3,"肥肠粉", 83, 155,ImmutableList.of(SpecialityEnum.DANCE,SpecialityEnum.RUNNING),"2",7));
        students.add(new Student(4,"红发", 48, 180,ImmutableList.of(SpecialityEnum.SWIMMING,SpecialityEnum.RUNNING),"2",1));
        students.add(new Student(5,"李黑炭", 11, 123,ImmutableList.of(SpecialityEnum.DANCE,SpecialityEnum.SWIMMING),"1",6));
        students.add(new Student(6,"雪花女神龙", 23, 175, ImmutableList.of(SpecialityEnum.SING,SpecialityEnum.RUNNING),"2",5));
        students.add(new Student(7,"梅杰", 21, 168, ImmutableList.of(SpecialityEnum.RUNNING,SpecialityEnum.SWIMMING),"1",3));
        students.add(new Student(8,"梅炭", 19, 188, ImmutableList.of(SpecialityEnum.RUNNING,SpecialityEnum.SING),"1",2));
        students.add(new Student(9,"王德发", 19, 188, ImmutableList.of(SpecialityEnum.RUNNING,SpecialityEnum.SING),"1",null));
        return students;
    }

    /**
     * 获取学生的第一个爱好
     * @param s
     * @return
     */
    public static String getFirstLove(Student s){
        return s.getSpecialityEnums().get(0).getDescription();
    }

    /**
     * 修改一个学生的年纪
     * @param s
     * @param a
     * @return
     */
    public static Student modifyStudentAge(Student s,int a){
        s.setAge(a);
        return s;
    }
    public static Student modifyStudentAge(Double a){
        BigDecimal bd=new BigDecimal(a).setScale(0, BigDecimal.ROUND_HALF_UP);
        student.setAge(Integer.parseInt(bd.toString()));
        return student;
    }

    public static Student modifyStudentAge(Student student){
        student.setAge(200);
        return student;
    }
}
